  var hosts  = new Object();
  function agHost(hostElementID, id, height, width, backgroundcolor, sourceelement, source, windowlessmode, framerate, errorhandler) {
    var hostElement = document.getElementById(hostElementID);
    var innerHTML;
//IE install
    if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1)) {

      innerHTML = '<object id="'+id+'" height="'+height+'" width="'+width+'" codebase="http://jscratch/install/cab/agctrl.cab" classid="CLSID:32C73088-76AE-40F7-AC40-81F62CB2C1DA">';
      if (sourceelement != null) {
          innerHTML += ' <param name="SourceElement" value="'+sourceelement+'" />';
      }
      if (source != null) {
          innerHTML += ' <param name="Source" value="'+source+'" />';
      }
      if (framerate != null) {
          innerHTML += ' <param name="MaxFrameRate" value="'+framerate+'" />';
      }
      if (errorhandler != null) {
          innerHTML += ' <param name="OnError" value="'+errorhandler+'" />';
      }
      if (backgroundcolor != null) {
          innerHTML += ' <param name="BackgroundColor" value="'+backgroundcolor+'" />';
      }
      if (windowlessmode != null) {
          innerHTML += ' <param name="WindowlessMode" value="'+windowlessmode+'" />';
      }
      innerHTML += '<\/object>';
    }

    //FF/Windows Install
    else if((window.GeckoActiveXObject && navigator.userAgent.indexOf('Windows') != -1)) {
      innerHTML = '<embed id="'+id+'" height="'+height+'" width="'+width+'" pluginspage="http://jscratch/install/xpi/agctrl.xpi"';
         if (source != null) {
             innerHTML += '" Source="'+source;
         }
         if (sourceelement != null) {
          innerHTML += '" SourceElement"'+sourceelement;
         }
         if (framerate != null) {
             innerHTML += '" MaxFrameRate="'+framerate;
         }
         if (errorhandler != null) {
             innerHTML +='" OnError="'+errorhandler;
         }
         if (backgroundcolor != null) {
             innerHTML += '" BackgroundColor="'+backgroundcolor;
         }
         if (windowlessmode != null) {
             innerHTML += '" WindowlessMode="'+windowlessmode;
         }
      innerHTML += '" type="application/ag-plugin"/>';

      }

    //MAC Install
      else if(navigator.userAgent.indexOf("Macintosh") != -1){
          innerHTML = '<embed id="'+id+'" height="'+height+'" width="'+width+'" pluginspage="http://jscratch/install/dmg/WPFe.dmg"';
         if (source != null) {
             innerHTML += '" Source="'+source;
         }
         if (sourceelement != null) {
          innerHTML += '" SourceElement"'+sourceelement;
         }
         if (framerate != null) {
             innerHTML += '" MaxFrameRate="'+framerate;
         }
         if (errorhandler != null) {
             innerHTML +='" OnError="'+errorhandler;
         }
         if (backgroundcolor != null) {
             innerHTML += '" BackgroundColor="'+backgroundcolor;
         }
         if (windowlessmode != null) {
             innerHTML += '" WindowlessMode="'+windowlessmode;
         }
      innerHTML += '" type="application/ag-plugin"/>';

      }


    hostElement.innerHTML = innerHTML;
  }